# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix

# split panes using | and -
bind _ split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %

set -s escape-time 10       # faster command sequences
set -sg repeat-time 200     # increase repeat timeout

# Set window notifications
# setw -g monitor-activity on
# set -g visual-activity off

# window navigation
unbind n
unbind p
bind -r C-h previous-window # select previous window
bind -r C-l next-window     # select next window
bind Tab last-window        # move to last active window

# switch panes using Alt-arrow without prefix
bind -n C-h select-pane -L
bind -n C-l select-pane -R
bind -n C-k select-pane -U
bind -n C-j select-pane -D

# move status line to top
set -g status-position top

# $TERM, fix true color
# How the color works still isn't very clear to me.
set  -g default-terminal "tmux-256color"
set -ag terminal-overrides ",xterm-256color:RGB"

# Use clipboard for copy
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'

# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
    | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h'  'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j'  'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k'  'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l'  'select-pane -R'
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
    "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\'  'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
    "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\'  'select-pane -l'"

bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l

# Enable mouse mode (tmux 2.1 and above)
set -g mouse on

set-window-option -g automatic-rename off
set-option -g allow-rename off

# Hide the background color of the status bar
# set -g status-bg default


### status bar ###
# set -g status-justify centre # center align window list
set -g status-fg white
set -g status-bg default
set -g status-style bright

# Make the active style brighter
set-window-option -g window-status-current-style fg="#79CDCD",bg=default,bright

set-window-option -g window-status-style fg=white,bg=default,dim

set -g status-right ''

# setw -g window-status-current-style fg='white', bg='default'
# set-window-option -g window-status-current-fg white
# set-window-option -g window-status-current-bg default
# set-window-option -g window-status-current-attr bright
##################

# create session
# bind C-c new-session

# create session with name
bind C-c command-prompt -p "New session name: " "new -s '%1'"

############ Plugin ############
# List of plugins
#set -g @plugin 'tmux-plugins/tpm'
#set -g @plugin 'tmux-plugins/tmux-sensible'
#set -g @plugin 'tmux-plugins/tmux-sessionist'

# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'git@github.com:user/plugin'
# set -g @plugin 'git@bitbucket.com:user/plugin'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
#run '~/.tmux/plugins/tpm/tpm'

